home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Software Vault: The Diamond Collection
/
The Diamond Collection (Software Vault)(Digital Impact).ISO
/
cdr13
/
tlt003.zip
/
TLT.C
< prev
next >
Wrap
Text File
|
1995-01-03
|
6KB
|
260 lines
/* Text Listy Thing (TLT)
* By Simon Avery
* Compiled with PCC and included PCIO and EXEC modules linked in.
* Version .003 Released 21:44:17 3 January 1995
* FreeWare - See TLT.DOC for more information
***/
#include <stdio.h>
char *buf1; /* Store start-up time in buf1 */
void main()
{
printf("
"); /* Ansi code to hide ink */
times(buf1); /* Store start-up time in buf1 */
white(); /* Ansi routine to change to default colours */
banner3(); /* Show banner3 */
mainloop(); /* Goto main routine */
}
mainloop()
{
white ();
int wordcount; /* Main wedge */
wordcount = 0;
FILE *fp1; /* Ask for filename */
char oneword[100],filename[25];
char *c;
printf("Name of file to view -> ");
printf("
"); /* Ansi code brght yell on blue bgrnd. */
scanf("%s",filename); /* read the desired filename */
fp1 = fopen(filename,"r");
if (fp1 == NULL) /* Check to see if file is there */
not_there();
else {
scr_clr(); /* Found file, print banner 1 and */
banner1(); /* show banner1 */
do
{
c = fgets(oneword,100,fp1); /* get one line from the file */
printf("%s",oneword); /* display it on the monitor */
wordcount = wordcount +1;
if (wordcount >= 20) /* Show 20 lines of text */
{
wordcount=0;
printf("
");
scr_rowcol(23,43);
printf("File: %s",filename); /* Print filename at bottom right */
stopbit (); /* Wait for a key... */
}
} while (c != NULL); /* Repeat until end of file */
}
fclose(fp1);
white();
banner4();
waitspace();
mainloop();
}
void white()
{
printf("
"); /* Ansi code for default DOS colours*/
}
quit()
{
white();
exit();
}
stopno ()
{
scr_clr();
white();
char *buf; /* Print time started and time now (ended) */
times(buf);
printf("\nTime started: %s. Time now: %s.\n",buf1,buf);
printf("Text Listy Thing (TLT V.003) terminated normally. (c) 1995 Simon Avery. √\n");
quit();
}
stopbit (string)
char *string[];
{
banner2();
waitspace();
scr_clr();
banner1();
}
waitspace()
{
/* Wait for any key */
int c;
c = getchar("%d",&c); /* get a character */
/* and check to see if it's one of the hotkeys */
if (c == 81) /* Dec code for 'Q' */
{stopno();}
if (c == 113) /* Dec code for 'q' */
{stopno();}
if (c == 27) /* Dec code for 'esc' */
{stopno();}
if (c == 68) /* D */
{dirlst();}
if (c == 100) /* d */
{dirlst();}
if (c == 63) /* ? */
{help();}
if (c == 72) /* H */
{help();}
if (c == 104) /* h */
{help();}
}
banner1 ()
{
/* Do top banner1 */
time();
printf("
"); /* Ansi code brght yell on blue bgrnd. */
scr_rowcol(0,14);
printf(" -= Text Listy Thing (TLT) By Simon Avery =- ");
printf("
"); /* Ansi code black on white bgrnd. */
scr_rowcol(0,65);
printf("CyberDwarf!(TM)");
white();
scr_rowcol(2,0);
}
banner2()
{
/* Do bottom banner2 */
scr_rowcol(23,0);
printf("
(Q)uit (D)ir (H)elp Any other key... ");
/* Now move cursor back to top of screen and start over */
white();
}
banner4()
{
/* Do bottom banner4 - end of file */
scr_rowcol(23,0);
printf("
-= END OF FILE =- (D)ir (Q)uit (H)elp Any other key to cycle. ");
/* Now move cursor back to top of screen and start over */
white();
}
not_there()
{
scr_clr();
scr_rowcol(2,0);
printf("Sorry, can't find that file.\n\n");
printf("Press any key to DIR or Q to abort.");
waitspace();
dirlst();
}
banner3()
{
/* Print Banner1 and move cursor down one line */
scr_clr();
banner1();
scr_rowcol(2,1);
}
dirlst()
{
scr_clr();
banner1();
exec("c:\\dos\\command.com", "/cdir /w");
mainloop();
}
help()
{
/* Really needs a way to save current screen, show help, then swap back in */
scr_clr();
banner1();
scr_rowcol(5,15);
printf("Text Listy Thing needs ANSI.SYS loaded in order to");
scr_rowcol(6,15);
printf(" display the colored headers. ");
scr_rowcol(8,15);
printf("This was my first ever 'C' program, written with ");
scr_rowcol(9,15);
printf(" PCC and didn't take very long. ");
scr_rowcol(11,15);
printf("TLT will display any Ansi codes within a document,");
scr_rowcol(12,15);
printf(" but will get confused about screen lengths with ");
scr_rowcol(13,15);
printf("some Ansi picture screens. Version .003 ");
scr_rowcol(15,15);
printf("D = Stops current file and prompts for a new file.");
scr_rowcol(16,15);
printf("Q = (or ESC) Halts TLT completely. ");
scr_rowcol(17,15);
printf("? = Print this screen. ");
scr_rowcol(19,15);
printf(" TLT is Freeware. (C'mon, would *you* buy it?) ");
banner2();
stopbit();
}
time()
{
scr_rowcol(0,0);
printf("
"); /* Ansi code black on white bgrnd. */
char *buf;
times(buf);
printf("%s",buf);
}